home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
C
/
LIB
/
UNIXLIB37B
/
!UnixLib37
/
src
/
unix
/
c
/
read
< prev
next >
Wrap
Text File
|
1996-11-09
|
1KB
|
56 lines
/****************************************************************************
*
* $Source: /unixb/home/unixlib/source/unixlib37/src/unix/c/RCS/read,v $
* $Date: 1996/10/30 22:04:51 $
* $Revision: 1.3 $
* $State: Rel $
* $Author: unixlib $
*
* $Log: read,v $
* Revision 1.3 1996/10/30 22:04:51 unixlib
* Massive changes made by Nick Burret and Peter Burwood.
*
* Revision 1.2 1996/05/06 09:01:35 unixlib
* Updates to sources made by Nick Burrett, Peter Burwood and Simon Callan.
* Saved for 3.7a release.
*
* Revision 1.1 1996/04/19 21:35:27 simon
* Initial revision
*
***************************************************************************/
static const char rcs_id[] = "$Id: read,v 1.3 1996/10/30 22:04:51 unixlib Rel $";
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/syslib.h>
#include <sys/dev.h>
#include <sys/unix.h>
__ssize_t
read (int fd, ptr_t data, size_t nbyte)
{
register struct file *f;
if (BADF (fd))
{
errno = EBADF;
return (__ssize_t)-1;
}
f = __u->file + fd;
if ((f->oflag & O_OMASK) == O_WRONLY)
{
errno = EBADF;
return (__ssize_t)-1;
}
/* Increment the number of times we have has to read from a device. */
__u->usage.ru_inblock++;
return (__ssize_t)__funcall ((*(__dev[major (f->dev)].read)), (minor (f->dev), data, nbyte, f));
}